//
//  LockViewController.m
//  基本框架
//
//  Created by runone02 on 2018/8/21.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "LockViewController.h"
#import "lockView.h"
#import "WHC_GestureUnlockScreenVC.h"

@interface LockViewController ()
/** */
@property (nonatomic, strong) lockView *lockView;
/** */
@property (nonatomic, strong) WHC_GestureUnlockScreenVC *vc;
@end

@implementation LockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadLockView];
    [self setupNavView];
    [self.vc setBackgroudImage:IMAGE(@"行")];
}

- (void)setupNavView{
    [self.navView.leftButton setTitle:@"返回" forState:UIControlStateNormal];
    [self.navView.centerButton setTitle:@"设置" forState:UIControlStateNormal];
}

- (void)loadLockView{
    self.lockView = [[lockView alloc]init];
    [self.view addSubview:self.lockView];
    [self.lockView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kTopBarHeight);
        make.left.right.bottom.mas_equalTo(self.view);
    }];
    [self.lockView.numberButton addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.lockView.pathButton addTarget:self action:@selector(pathButtonClick:) forControlEvents:UIControlEventTouchUpInside];
     [self.lockView.reviseButton addTarget:self action:@selector(reviseButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.lockView.deleteButton addTarget:self action:@selector(deleteButtonClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)numberButtonClick:(UIButton *)btn{
    [WHC_GestureUnlockScreenVC setUnlockScreenWithType:ClickNumberType];    
}

- (void)pathButtonClick:(UIButton *)btn{
    [WHC_GestureUnlockScreenVC setUnlockScreenWithType:GestureDragType];
}

- (void)reviseButtonClick:(UIButton *)btn{
  
    if (![WHC_GestureUnlockScreenVC modifyUnlockPasswrodWithVC:self]) {
        [self alert:@"先设置手势密码再修改"];
    }
}

- (void)deleteButtonClick:(UIButton *)btn{

    if(![WHC_GestureUnlockScreenVC removeGesturePasswordWithVC:self]){
        [self alert:@"先设置手势密码再删除"];
    }
}

- (void)alert:(NSString *)msg{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:msg message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
@end
